/*
 *  WitchCat.cpp
 *  Untitled
 *
 *  Created by Guo Wei Tan on 1/20/14.
 *  Copyright 2014 __MyCompanyName__. All rights reserved.
 *
 */

#include "WitchCat.h"
#include "Cats/CatSpriteLoader.h"
#include "Cats/CatStates/CatState_Base_Chase.h"
#include "Cats/CatStates/CatState_Base_Obstacle.h"
#include "Cats/CatStates/CatState_Witch_Attack.h"
#include "Cats/CatStates/CatState_Base_Flank.h"
#include "Cats/CatStates/CatState_Witch_Skill.h"
#include "Cats/CatStates/CatState_Base_Injured.h"
#include "Cats/CatStates/CatState_Base_Dying.h"
#include "Cats/CatStates/CatState_Base_Dead.h"

#include "Character/Character.h"
#include "Map/GameMap.h"
//========================== C O N S T R U C T O R ==============================
WitchCat::WitchCat(): BaseCat()
{
	//BASE VALUES
	//animation
	RECT_BUFFER_RADIUS = 20;
	//movement
	VARYING_SPEED = 20;
	BASE_SPEED = 180;
	BASE_SPEED_MULTIPLIER = 1;
	//attack
	BASE_ATTACK_RANGE_GRID = 9;
	BASE_ATTACK_DAMAGE = 1;
	BASE_ATK_SPEED = BASE_SPEED;

	//obstacle/stop
	BASE_OBSTACLE_HIT_CHANCE = 0; //no obstacle hit chance
	SLOW_SPEED_MULTIPLIER = 1;
	SLOW_DURATION = 0;

	//jump
	BASE_JUMP_HEIGHT = 30;
	BASE_JUMP_SPEED = BASE_SPEED;

	//skill
	SKILL_AVAILABLE = true;
	BASE_SKILL_COOLDOWN = 10;
	//health
	BASE_HEALTH = 3;
	//cat type
	CAT_TYPE = WITCH_CAT;

	setImmunity(INJURY_EARTHQUAKE, INJURY_BURNT);
}

/*!
    @function initStates
    @result		initialize the states of the cat.
    			TO BE OVERRIDEN BY CHILDREN CLASSES
 */
void WitchCat::initStates()
{
	_myCatStates = new CatState*[CAT_STATE_NUM];
	_myCatStates[CAT_CHASE] = new CatState_Base_Chase(this);
	_myCatStates[CAT_OBSTACLE] = new CatState_Base_Obstacle(this);
	_myCatStates[CAT_ATTACK] = new CatState_Witch_Attack(this);
	_myCatStates[CAT_FLANK] = new CatState_Witch_Attack(this); //witch cat has no flank state
	_myCatStates[CAT_SKILL] = new CatState_Witch_Skill(this);
	_myCatStates[CAT_INJURED] = new CatState_Base_Injured(this);
	_myCatStates[CAT_DYING] = new CatState_Base_Dying(this);
	_myCatStates[CAT_DEAD] = new CatState_Base_Dead(this);

	_myCatStates[CAT_CHASE]->onEnter();
	_currentCatState = CAT_CHASE;
	_previousCatState = CAT_CHASE;
}

/*!
    @function createCat
    @result		returns a cat with loaded sprites
 */
WitchCat* WitchCat::createCat()
{
	WitchCat *cat = new WitchCat();

	if( cat && cat->initWithSpriteFrame(CatSpriteLoader::getSpriteFrame(cat->getCatType())))
	{
		cat->setScale(GameMap::getInstance()->getScaleFactor());
		cat->initCat();
		cat->autorelease();
		return cat;
	}

	CC_SAFE_DELETE(cat);
	return NULL;
}




